# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Gordin <9ordin @t gmail dot com>

_gemname=paint
pkgname=ruby-${_gemname}
pkgver=2.3.0
pkgrel=2
pkgdesc='Ruby paint manages terminal colors and effects'
url='https://github.com/janlelis/paint'
arch=('any')
license=('MIT')
depends=('ruby')
makedepends=('ruby-rake' 'ruby-rspec' 'ruby-rainbow' 'ruby-term-ansicolor')
options=('!emptydirs')
source=(${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('296c73ae3066f2114fdadfbaab81bb0f4b4893c8ab5b41d5dc8ef511104541df2a1bfd9f35582742769cb32e11ad22527fef7938952147eec6d4d36526fb5f60')
b2sums=('6f9028c26966ba5c7e0b7de0e9957b2cd73585679347f281a07d2ac95ab5d12f043580cc5afba8f68fd416854c1824b18ed1f53e11f24277f1718786729e66b9')

prepare() {
  cd ${_gemname}-${pkgver}
  sed -r 's|~>|>=|g' -i paint.gemspec
  sed '/.travis.yml/d' -i paint.gemspec
}

build() {
  cd ${_gemname}-${pkgver}
  rake gems
}

check() {
  cd ${_gemname}-${pkgver}
  rake test
}

package() {
  cd ${_gemname}-${pkgver}
  local _gemdir="$(gem env gemdir)"
  gem install --ignore-dependencies --no-user-install -i "${pkgdir}${_gemdir}" \
    -n "${pkgdir}/usr/bin" pkg/${_gemname}-${pkgver}.gem
  install -Dm 644 MIT-LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 README.md CHANGELOG.md -t "${pkgdir}/usr/share/doc/${pkgname}"

  cd "${pkgdir}/${_gemdir}"
  rm -rf cache gems/${_gemname}-${pkgver}/{ext,lib/*/*.so} \
    extensions/*/*/${_gemname}-${pkgver}/{mkmf.log,gem_make.out}
}

# vim: ts=2 sw=2 et:
